//
//  Team9dairyDiscussCell.m
//  Team9Project
//
//  Created by dlios on 15/10/17.
//  Copyright © 2015年 apple. All rights reserved.
//

#import "Team9dairyDiscussCell.h"
#import <Masonry.h>
#import "Team9diaryDiscussModel.h"
@implementation Team9dairyDiscussCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self creatAllView];
    }
    return self;
}


- (void)setDisModel:(Team9diaryDiscussModel *)disModel{
    if (_disModel != disModel) {
        _disModel = disModel;
    }

    
    [Team9Tool sd_imageView:self.headImageView image:disModel.author_face placeholder:[UIImage imageNamed:@"333"]];
    [Team9Tool imageView:self.headImageView type:disModel.author_type Id:disModel.author_id viewController:self.vc];
    self.userNameLabel.text = disModel.author_nick;
    self.describleLabel.text = disModel.content;
    self.timeLabel.text = disModel.create_time;
    
    
}

-(void)creatAllView
{
    
  
    
    
    // 头像
    self.headImageView = [[UIImageView alloc] init];
    [self.contentView addSubview:self.headImageView];
    self.headImageView.layer.masksToBounds = YES;
    self.headImageView.backgroundColor = [UIColor clearColor];
    self.headImageView.layer.cornerRadius = 20 / 375.0 * WIDTH ;
    
    // 名字
    self.userNameLabel = [[Team9BaseLabel alloc] init];
    self.userNameLabel.font = [UIFont systemFontOfSize:15 / 375.0 * WIDTH];
    [self.contentView addSubview:self.userNameLabel];
    self.userNameLabel.textColor = [UIColor orangeColor];
    self.userNameLabel.backgroundColor = [UIColor clearColor];
    
    
    
    // 状态
    self.describleLabel = [[Team9BaseLabel alloc] init];
    self.describleLabel.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.describleLabel];
    self.describleLabel.numberOfLines = 0;
    [self.describleLabel sizeToFit];
    self.describleLabel.font = [UIFont systemFontOfSize:13 / 375.0 * WIDTH];
    
    // 时间
    self.timeLabel = [[Team9BaseLabel alloc] init];
    self.timeLabel.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.timeLabel];
    self.timeLabel.font = [UIFont systemFontOfSize:13 / 375.0 * WIDTH];
    self.timeLabel.textAlignment = NSTextAlignmentRight;
    
    [self makeConstraints];
    
}



- (void)makeConstraints{


    
    // 头像
    [self.headImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView.mas_top).offset(10 / 375.0 * WIDTH);
        make.left.equalTo(self.contentView.mas_left).offset(10 / 375.0 * WIDTH);
        make.width.equalTo(self.headImageView.mas_height);
        make.width.equalTo(self.contentView.mas_width).multipliedBy(0.11);
        
        
    }];
    
    // 名字
    [self.userNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView.mas_top).offset(10 / 375.0 * WIDTH);
        make.left.equalTo(self.headImageView.mas_right).offset(10 / 375.0 * WIDTH);
        make.width.equalTo(self.userNameLabel.mas_height).multipliedBy(8.3);
        make.width.equalTo(self.contentView.mas_width).multipliedBy(0.5);
        
    }];
    
    // 表述
    [self.describleLabel mas_updateConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.headImageView.mas_bottom).offset(10 / 375.0 * WIDTH);
        make.left.equalTo(self.headImageView.mas_right).offset(10 / 375.0 * WIDTH);
        make.right.equalTo(self.contentView.mas_right).offset(-10 / 375.0 * WIDTH);
        
    }];

    // 时间
    [self.timeLabel mas_updateConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView.mas_top).offset(10 / 375.0 * WIDTH);
        make.right.equalTo(self.contentView.mas_right).offset(-10 / 375.0 * WIDTH);
        make.width.mas_equalTo(80 / 375.0 * WIDTH);
        make.height.mas_equalTo(22 / 375.0 * WIDTH);
        
    }];

}


-(void)layoutSubviews
{
    [super layoutSubviews];
    
    
    
}


@end
